﻿.PHONY	= clean
GCC		= cl.exe

SUBDIRS=$(shell ls -l | grep ^d | awk '{if($$9 != "debug") print $$9}')
ROOT_DIR=$(shell pwd)
BIN=myapp
OBJS_DIR=debug\obj
BIN_DIR=debug\bin
INCLUDES = -I. -I./queue
CFLAGS=$(INCLUDES)
CUR_SOURCE=${wildcard *.c}
CUR_OBJS=${patsubst %.c, %.obj, $(CUR_SOURCE)}
export GCC BIN OBJS_DIR BIN_DIR ROOT_DIR
all:$(SUBDIRS) $(CUR_OBJS) DEBUG

$(SUBDIRS):ECHO
	make -C  $@
DEBUG:ECHO
	make -C debug
ECHO:
	echo $(SUBDIRS)
	
$(CUR_OBJS):%.obj:%.c
	$(GCC) $(CFLAGS) -c $^  /Fo$(ROOT_DIR)\$(OBJS_DIR)\$@
clean:
	del /Q $(ROOT_DIR)\$(OBJS_DIR)\*.obj
	del /Q $(ROOT_DIR)\$(BIN_DIR)\*